<?php
    
    $cod = $_POST['codigo'];

    include ("conecta.php");
    
    $sql = "SELECT tipo,idUsuario FROM documento WHERE codigo='$cod'";
    $result = mysql_query($sql) or trigger_error(mysql_error().$sql);
    $count = mysql_num_rows($result);
    
    if($count == 1) {
        $row = mysql_fetch_array($result)  or trigger_error(mysql_error().$sql);
        session_start();
        $_SESSION['doc'] = $row;
        mysql_close();
        header("location:../doc.php");
    } else {
        mysql_close();
        header("location:../invalid.php");
    }
    
?>
